//
//  TiXianViewController.m
//  ZhiBoYuan
//
//  Created by coder_di on 2018/4/24.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "TiXianViewController.h"

@interface TiXianViewController ()

@property (nonatomic, strong)UITextField *yinhangkaTextField;
@property (nonatomic, strong)UITextField *kaihuhangTextField;

@property(nonatomic, strong)UITextField *yanzhengmaTextField;
@property(nonatomic, strong)UITextField *nePassWordTextField;

@property (nonatomic, strong)UILabel *shengyuLable;

@end

@implementation TiXianViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"学豆提现";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUI];
    
}

//提现
-(void)tixianAction{
    SGParameter *parameter  = [[SGParameter alloc] init];
    parameter.body = @{@"band_address":_kaihuhangTextField.text,
                       @"band_number":_yinhangkaTextField.text,
                       @"income_price":_nePassWordTextField.text,
                       @"true_name":_yanzhengmaTextField.text
                       };
    
    [SGHttpTool POST:[NSString stringWithFormat:@"%@g=Client&m=Ucenter&a=incomeAudit",HTTPP] parameter:parameter sucess:^(id responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"status"] intValue] == 200) {
//            [MBProgressHUD showTextOnly:self.view message:responseObject[@"msg"] delay:2.0];
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"" message:responseObject[@"msg"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil, nil];
            [alertView show];
            
            [self.navigationController popViewControllerAnimated:YES];
            
        }else{
            
            [MBProgressHUD showTextOnly:self.view message:responseObject[@"msg"] delay:2.0];
        }
        
        
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
        
    }];
    
}

-(void)quanbuAction{
    _nePassWordTextField.text = [ZYUserManager userInfo].left_xuedou;
    
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [_yinhangkaTextField resignFirstResponder];
    [_yanzhengmaTextField resignFirstResponder];
    [_nePassWordTextField resignFirstResponder];
}

-(void)setUI{
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 30 * KscreenHeight + NAVIGATION_BAR_HEIGHT, 100 * KscreenWidth, 30 *KscreenHeight)];
    lable.text = @"银行卡号";
    lable.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    [self.view addSubview:lable];
    
    _yinhangkaTextField = [[UITextField alloc]initWithFrame:CGRectMake(120 * KscreenWidth, 30 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 140 * KscreenWidth, 30 * KscreenHeight)];
    _yinhangkaTextField.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    _yinhangkaTextField.placeholder = @"请输入银行卡号";
    [self.view addSubview:_yinhangkaTextField];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 80 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 40 * KscreenWidth, 1 * KscreenHeight)];
    line.backgroundColor = ZhuTiColor;
    [self.view addSubview:line];
    
    
    UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 100 * KscreenHeight + NAVIGATION_BAR_HEIGHT, 100 * KscreenWidth, 30 *KscreenHeight)];
    lable1.text = @"开户行";
    lable1.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    [self.view addSubview:lable1];
    
    _kaihuhangTextField = [[UITextField alloc]initWithFrame:CGRectMake(120 * KscreenWidth, 100 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 240 * KscreenWidth, 30 * KscreenHeight)];
    _kaihuhangTextField.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    _kaihuhangTextField.placeholder = @"请输入开户行";
    [self.view addSubview:_kaihuhangTextField];
    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 150 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 40 * KscreenWidth, 1 * KscreenHeight)];
    line1.backgroundColor = hui2Color;
    [self.view addSubview:line1];
    
    
    
    UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 170 * KscreenHeight + NAVIGATION_BAR_HEIGHT, 100 * KscreenWidth, 30 *KscreenHeight)];
    lable2.text = @"姓名";
    lable2.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    [self.view addSubview:lable2];
    
    _yanzhengmaTextField = [[UITextField alloc]initWithFrame:CGRectMake(120 * KscreenWidth, 170 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 140 * KscreenWidth, 30 * KscreenHeight)];
    _yanzhengmaTextField.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    _yanzhengmaTextField.placeholder = @"请输入姓名";
    [self.view addSubview:_yanzhengmaTextField];
    
    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 220 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 40 * KscreenWidth, 1 * KscreenHeight)];
    line2.backgroundColor = hui2Color;
    [self.view addSubview:line2];

    
    
    UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 240 * KscreenHeight + NAVIGATION_BAR_HEIGHT, 100 * KscreenWidth, 30 *KscreenHeight)];
    lable3.text = @"提现学豆";
    lable3.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    [self.view addSubview:lable3];
    
    _nePassWordTextField = [[UITextField alloc]initWithFrame:CGRectMake(120 * KscreenWidth, 240 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 140 * KscreenWidth, 30 * KscreenHeight)];
    _nePassWordTextField.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    _nePassWordTextField.placeholder = @"请输入要提现的学豆";
    [self.view addSubview:_nePassWordTextField];
    
    UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 290 * KscreenHeight + NAVIGATION_BAR_HEIGHT, ScreenWidth - 40 * KscreenWidth, 1 * KscreenHeight)];
    line3.backgroundColor = hui2Color;
    [self.view addSubview:line3];
    
    
    
    
    
    UIButton *goChongZHi = [UIButton buttonWithType:(UIButtonTypeCustom)];
    goChongZHi.frame = CGRectMake(20 * KscreenWidth, Screenheight - 140 * KscreenHeight,ScreenWidth - 40 * KscreenWidth, 50 * KscreenHeight);
    [goChongZHi setTitle:@"去提现" forState:0];
    goChongZHi.backgroundColor = ZhuTiColor;
    goChongZHi.font = [UIFont systemFontOfSize:18 * KscreenWidth];
    [goChongZHi setTitleColor:[UIColor whiteColor] forState:0];
    
    [goChongZHi addTarget:self action:@selector(tixianAction) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.view addSubview:goChongZHi];
    
    
    
    
    
    _shengyuLable = [[UILabel alloc]initWithFrame:CGRectMake(20 * KscreenWidth, 310 + NAVIGATION_BAR_HEIGHT, 175 * KscreenWidth, 20 * KscreenHeight)];
    _shengyuLable.text = [NSString stringWithFormat:@"当前剩余学豆:%@,",[ZYUserManager userInfo].left_xuedou];
    _shengyuLable.textColor = hui5Color;
    _shengyuLable.textAlignment = NSTextAlignmentRight;
    _shengyuLable.font = [UIFont systemFontOfSize:15 * KscreenWidth];
    [self.view addSubview:_shengyuLable];
    
    UIButton *btnn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btnn.frame = CGRectMake(180 * KscreenWidth, 310 + NAVIGATION_BAR_HEIGHT, 100 * KscreenWidth, 20 * KscreenHeight);
    [btnn setTitle:@"全部提现" forState:0];
    btnn.font = [UIFont systemFontOfSize:15 * KscreenWidth];
    [btnn setTitleColor:[UIColor blueColor] forState:0];
    [btnn addTarget:self action:@selector(quanbuAction) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:btnn];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
